package com.run2code.idea.plugin.codegenerate.factory;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.run2code.idea.plugin.codegenerate.biz.generate.service.ICodeGenerator;
import com.run2code.idea.plugin.codegenerate.biz.generate.service.impl.CodeGeneratorImpl;
import com.run2code.idea.plugin.codegenerate.ui.CodeGenerateUi;
import org.jetbrains.annotations.NotNull;


/**
 * 代码生成工具窗口工厂
 * 关注公众号【奔跑的码畜】，一起进步不迷路
 *
 * @author 第七人格
 * @date 2023/10/27
 */
public class CodeGenerateWindowFactory implements ToolWindowFactory {

    /**
     * 创建右侧窗口
     *
     * @param project    项目
     * @param toolWindow 工具窗口
     */
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        // 获取内容工厂的实例
        ContentFactory contentFactory = ContentFactory.getInstance();
        CodeGenerateUi codeGenerateUi = new CodeGenerateUi(project);
        // 获取 ToolWindow 显示的内容
        Content content = contentFactory.createContent(codeGenerateUi.getMain(), "", false);
        // 设置 ToolWindow 显示的内容
        toolWindow.getContentManager().addContent(content);
    }

}
